﻿using HuChaHuRen.HeNan.XiangCheng.Models;
using MiniExcelLibs;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HuChaHuRen.HeNan.XiangCheng.Common
{
    public class ExcelOp
    {

        public static List<CheckItemComp> ReadCheckItemComp(string path)
        {
            if(!File.Exists(path))
            {
                return new List<CheckItemComp>();
            }
            var rows = MiniExcel.Query<CheckItemComp>(path);
            return rows.ToList();
        }

        public static void UpdateComp(List<CheckItemComp> compList, string path)
        {
            if (!File.Exists(path))
            {
                return;
            }

            MiniExcel.SaveAs(path, compList, overwriteFile:true);
        }
    }
}
